From: Yongjie Ren Date: Tue, 21 Jun 2011 14:31:34 +0000 (+0100) Subject: libxl: remove O_CLOEXEC in xl_cmdimpl.c X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=cd703ed54853dcaf51fb61b29f2f55e7c88f1d56;p=xen.git libxl: remove O_CLOEXEC in xl_cmdimpl.c Some old linux kernels such as 2.6.18 don't define O_CLOEXEC, so remove O_CLOEXEC in xl_cmdimpl.c and replace with fcntl. Signed-off-by: Yongjie Ren Committed-by: Ian Jackson --- diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index ecfcac484b..77f9bc9359 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -199,11 +199,16 @@ static int acquire_lock(void) fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; - fd_lock = open(lockfile, O_WRONLY|O_CREAT|O_CLOEXEC, S_IWUSR); + fd_lock = open(lockfile, O_WRONLY|O_CREAT, S_IWUSR); if (fd_lock < 0) { fprintf(stderr, "cannot open the lockfile %s errno=%d\n", lockfile, errno); return ERROR_FAIL; } + if (fcntl(fd_lock, F_SETFD, FD_CLOEXEC) < 0) { + close(fd_lock); + fprintf(stderr, "cannot set cloexec to lockfile %s errno=%d\n", lockfile, errno); + return ERROR_FAIL; + } get_lock: rc = fcntl(fd_lock, F_SETLKW, &fl); if (rc < 0 && errno == EINTR)